
use tables/estimates_bs_ci, clear 

gen w_pop = ub_pop - lb_pop
foreach b in non_m non_i clear_m clear_i {
	gen w_`b' = ub_`b' - lb_`b'
	gen w_ci_`b' = p975_`b' - p025_`b'
	gen ratio_`b' = w_`b' / w_pop
	gen ratio_ci_`b' = w_ci_`b' / w_pop
}

gen c0 = "Sample & assumption &confidence interval &"
gen c1 = "Width of bound, relative to population \\"

local row = 1
foreach s in non clear {
	if "`s'" == "non" local ns "Non-ICLI"
	if "`s'" == "clear" local ns "Clear cause"
	
	foreach b in m i {
		if "`b'" == "m" local nb "h-monotonicity"
		if "`b'" == "i" local nb "h-independence"
			
		
		foreach ci in "" _ci {
			if "`ci'" == "" local nc = "No"
			if "`ci'" == "_ci" local nc = "Yes"
			sum ratio`ci'_`s'_`b'
			local ++row
			replace c0 = "`ns' & `nb' & `nc' & " in `row'
			replace c1 = string(r(mean), "%3.2f") + " \\ " in `row'
		}
	}
}

count if ratio_ci_non_m > 1
count if ratio_ci_non_i > 1

list c0 c1 in 1/`row', noobs clean
outsheet c0 c1 in 1/`row' using tables/width_shrinkage.tex, replace noquote ///
	nonames delimit(" ")
	
